<template>
    <div class="Header">
        <div class="company">
            <img src="@/assets/define.png" class="logo" alt="img">
            <div class="name">IoT Center</div>
        </div>
        <div class="right">
            <el-dropdown trigger="click">
                <div class="user">
                    <el-icon>
                        <User/>
                    </el-icon>
                    <div class="name">用户名</div>
                    <el-icon class="el-icon--right">
                        <arrow-down/>
                    </el-icon>
                </div>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>
        </div>
    </div>
</template>

<script lang="ts" setup>
    import {ArrowDown, User} from '@element-plus/icons-vue'
    import {useRouter} from "vue-router";

    const router = useRouter()

    // 退出登录
    function logout() {
        sessionStorage.clear();
        router.replace({path: '/'})
    }
</script>

<style lang="less" scoped>
  .Header {
    height: 100%;
    background-color: rgb(0, 21, 41);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.8);

    .company {
      width: calc(200px - 0.8px);
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: rgba(0, 21, 41, 0.90);

      .logo {
        width: 44px;
        height: 38px;

      }

      .name {
        font-size: 18px;
        color: white;
        margin-left: 15px;
      }
    }

    .right {
      margin-right: 66px;
      display: flex;
      align-items: center;

      .user {
        display: flex;
        align-items: center;
        cursor: pointer;

        .head {
          height: 24px;
          width: 24px;
          border-radius: 50%;
        }

        .name {
          margin-left: 8px;
        }
      }
    }
  }
</style>
